from flask import Flask, request

app = Flask(__name__)


@app.route('/weixin', methods=['GET'])
def weixin_auth():
    signature = request.args.get('signature')
    timestamp = request.args.get('timestamp')
    nonce = request.args.get('nonce')
    echo_str = request.args.get('echo_str')
    # 实现Token验证和加密验证
    # 验证成功后返回echo_str，微信小程序会原样返回该值
    # 实现你的业务逻辑，比如用户登录、获取用户信息等
    # ...
    return echo_str


if __name__ == '__main__':
    app.run(debug=True)